﻿using System;
using System.Collections.Generic;

using NUnit.Framework;
using Rhino.Mocks;

/*
 * based on code from:
 * http://flux88.com/TheTransitionFromTDDToBDD.aspx
 */

namespace Quiziqal.Core.ForTesting
{
    public abstract class SpecificationBase
    {
        protected Exception ExceptionThrown { get; private set; }

        [SetUp]
        public void Setup()
        {
            EstablishContext();

            try
            {
                When();
            }
            catch (Exception exc)
            {
                ExceptionThrown = exc;
            }
        }

        protected T Mock<T>() where T : class
        {
            return MockRepository.GenerateMock<T>();
        }

        protected T Stub<T>() where T : class
        {
            return MockRepository.GenerateStub<T>();
        }

        protected abstract void EstablishContext();
        protected abstract void When();

        [TearDown]
        public virtual void TearDown()
        {
        }
    }
}